chore(tests): add tests to validate caching works properly#62
Draft
chore(tests): add tests to validate caching works properly#62
Conversation
caugner
requested changes
Oct 17, 2025
Contributor
There was a problem hiding this comment.
Overall looking good.
Nits:
- Default to sending
accept-language: enon all requests, as that would be more realistic. - Extract some urls as constants.
- Extract a helper function that avoids duplication and makes the test cases more readable (three parameters: original URL, expected URL, options { acceptLanguage, preferredLanguage })
PS: Note that conventional commits includes a test: prefix.
Comment on lines
+8
to
+9
| let response = await fetch(new URL("/en-US/docs/Web", BASE_URL)); | ||
| assert.ok(response.url.endsWith("/en-US/docs/Web"), response.url); |
Contributor
There was a problem hiding this comment.
Is there a way to skip the test instead (if that URL is not available)?
Contributor
There was a problem hiding this comment.
Before landing this test, we should make sure that running the tests locally doesn't make requests to stage.
Afaik, if we just define the test like this, then node --test . would execute it.
| cookie: "preferredlocale=fr", | ||
| }), | ||
| }); | ||
| assert.ok(response.url.endsWith("/fr/docs/Web"), response.url); |
Contributor
There was a problem hiding this comment.
Suggested change
| assert.ok(response.url.endsWith("/fr/docs/Web"), response.url); | |
| assert.strictEqual("/fr/docs/Web", URL.parse(response.url).pathname); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's some slightly complicated caching logic to port to fastly, manually testing seems like a bad idea.
Draft while this is a work in progress.